import { isExport } from '../utils.js';
/**
 * An export looks like this in AST form:
 * {
 *   type: 'mdxjsEsm',
 *   data: {
 *     estree: {
 *       type: 'Program',
 *       sourceType: 'module'
 *       body: [
 *         type: 'ExportNamedDeclaration',
 *         ...
 *       ]
 *     }
 *   }
 * }
 * @param content mdx ast node
 * @returns whether the node includes an export or not
 */
export const nodeIncludesExport = (node) => {
    var _a, _b, _c, _d, _e, _f, _g;
    if (node.type !== 'mdxjsEsm') {
        return false;
    }
    if (((_b = (_a = node.data) === null || _a === void 0 ? void 0 : _a.estree) === null || _b === void 0 ? void 0 : _b.type) !== 'Program' &&
        ((_d = (_c = node.data) === null || _c === void 0 ? void 0 : _c.estree) === null || _d === void 0 ? void 0 : _d.sourceType) !== 'module') {
        return false;
    }
    if (!((_f = (_e = node.data) === null || _e === void 0 ? void 0 : _e.estree) === null || _f === void 0 ? void 0 : _f.body)) {
        return false;
    }
    for (const bodyChild of ((_g = node.data) === null || _g === void 0 ? void 0 : _g.estree).body) {
        if (isExport(bodyChild.type)) {
            return true;
        }
    }
    return false;
};
